package com.huawei.su;

import java.util.HashMap;
import java.util.Map;

public class BM7 {
    public static void main(String[] args) {

    }

    public ListNode EntryNodeOfLoop(ListNode pHead) {
        Map<ListNode,Integer> map = new HashMap<>();
        ListNode index = pHead;
        int count = 1;
        while (true){
            if(index == null){
                break;
            }
            if(map.containsKey(index)){
                return index;
            }
            map.put(index,count);
            count++;
            index = index.next;
        }
        return null;
    }
}
